﻿using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using OpenAdmin.Core.DbContextLocators;

namespace OpenAdmin.Core.Models;

/// <summary>
///  api资源表
/// </summary>
[Table("SysApiResource")]
public class SysApiResource : EntityBase<ApplicationDbContextLocator>, IEntityTypeConfigure<SysApiResource>
{
    /// <summary>
    /// 名称
    /// </summary>
    public string Name { get; set; }
    /// <summary>
    /// 标识
    /// </summary>
    public string Code { get; set; }
    /// <summary>
    /// api地址
    /// </summary>
    public string LinkUrl { get; set; }
    /// <summary>
    /// 排序
    /// </summary>
    public int Sort { get; set; }

    public void Configure(EntityTypeBuilder<SysApiResource> entityBuilder)
    {
        entityBuilder.Property(p => p.Name).HasMaxLength(50).IsRequired();
        entityBuilder.Property(p => p.Code).HasMaxLength(50);
        entityBuilder.Property(p => p.LinkUrl).HasMaxLength(50);
    }
}
